//
//  MainTabbarViewController.m
//  Lucky28
//
//  Created by zr on 2018/7/31.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MainTabbarViewController.h"
#import "HomeViewController.h"
#import "AskViewController.h"
#import "MustViewController.h"
#import "MyselfViewController.h"
#import "MainViewController.h"

@interface MainTabbarViewController ()

@end

@implementation MainTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI{
    
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];

    [UITabBar appearance].translucent = NO;

    HomeViewController * homeVC = [HomeViewController new];
    homeVC.title = @"首页";

    MustViewController * mustVC = [MustViewController new];
    mustVC.title = @"必备";

    AskViewController * askVC = [AskViewController new];
    askVC.title = @"问命";

    MyselfViewController * myselfVC = [MyselfViewController new];
    myselfVC.title = @"个人中心";


    MainViewController * homeNav = [[MainViewController alloc] initWithRootViewController:homeVC];
    MainViewController * mustNav = [[MainViewController alloc] initWithRootViewController:mustVC];
    MainViewController * askNav = [[MainViewController alloc] initWithRootViewController:askVC];
    MainViewController * myselfNav = [[MainViewController alloc] initWithRootViewController:myselfVC];

    homeNav.tabBarItem.image = [[UIImage imageNamed:@"shouye 2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    homeNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"shouye"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mustNav.tabBarItem.image = [[UIImage imageNamed:@"shequ2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mustNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"shequ"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    askNav.tabBarItem.image = [[UIImage imageNamed:@"xiaoxi 2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    askNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"xiaoxi"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    myselfNav.tabBarItem.image = [[UIImage imageNamed:@"gerenzhonngxing2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    myselfNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"gerenzhonngxing"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];


    //改变tabbarController 文字选中颜色(默认渲染为蓝色)
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:ColorWithRGB(0xDA4136)} forState:UIControlStateSelected];

    //创建一个数组包含四个导航栏控制器
    NSArray *vcArry = [NSArray arrayWithObjects:homeNav,mustNav,askNav,myselfNav,nil];

    //将数组传给UITabBarController
    self.viewControllers = vcArry;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
